package com.chuiyan.topnews;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class User extends Fragment implements View.OnClickListener {
    private CardView cardView;
    private View histroy;
    private View dianzan;
    private View shoucang;
    private View comment;
    private TextView loginUser;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.user, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        cardView = getView().findViewById(R.id.login);
        cardView.setOnClickListener(this);

        histroy = getView().findViewById(R.id.history);
        dianzan = getView().findViewById(R.id.dianzan);
        shoucang = getView().findViewById(R.id.shoucang);
        comment = getView().findViewById(R.id.comment);
        loginUser = getView().findViewById(R.id.loginUser);
        histroy.setOnClickListener((this));
        dianzan.setOnClickListener((this));
        shoucang.setOnClickListener((this));
        comment.setOnClickListener((this));
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.login:
                Intent intent1 = new Intent(getActivity(), Login.class);
                startActivity(intent1);
                break;
            case R.id.history:
                Intent intent2 = new Intent(getActivity(), Info.class);
                intent2.putExtra("classvalue", 2);
                startActivity(intent2);
                break;
            case R.id.dianzan:
                Intent intent3 = new Intent(getActivity(), Info.class);
                intent3.putExtra("classvalue", 3);
                startActivity(intent3);
                break;
            case R.id.shoucang:
                Intent intent4 = new Intent(getActivity(), Info.class);
                intent4.putExtra("classvalue", 4);
                startActivity(intent4);
                break;
            case R.id.comment:
                Intent intent5 = new Intent(getActivity(), Info.class);
                intent5.putExtra("classvalue", 5);
                startActivity(intent5);
                break;
            default:
                break;
        }
    }
}
